import {ref,onMounted,onUnmounted,onUpdated} from 'vue'

export default function useScroll (){
    const top = ref(0)

    const update = ()=> top.value = window.scrollY

    onMounted(()=>{
        window.addEventListener('scroll',update)
    })
    onUnmounted(()=>{
        window.removeEventListener('scroll',update)
    })
    onUpdated(()=>{
        console.log(top.value)
    })
    return{top}
}